package com.fit.entities;

import java.util.LinkedList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.apache.tapestry5.beaneditor.NonVisual;
import org.apache.tapestry5.beaneditor.Validate;

import com.fit.entities.manytomany.ProjSciField;

@Entity
@Table(name="project")
public class Project {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@NonVisual
	@Column(name = "id")
	private long id;
	@Validate("required")
	@Column(name = "name", nullable=false)
	private String name;
	@Validate("required")
	@Column(name = "keywords", nullable=false)
	private String keywords;
	@Validate("required")
	@Column(name = "abstract", nullable=true)
	private String abstrct;
	@ManyToOne(cascade = CascadeType.ALL, optional=false)
	@JoinColumn(name = "organization_id")
	private Organization organization;
	@ManyToOne(cascade = CascadeType.ALL, optional=false)
	@JoinColumn(name = "user_id")
	private User user;
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "pk.project")
	private List<ProjSciField> projSciField = new LinkedList<ProjSciField>();
	
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getKeywords() {
		return keywords;
	}
	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}
	public String getAbstrct() {
		return abstrct;
	}
	public void setAbstrct(String abstrct) {
		this.abstrct = abstrct;
	}
	public Organization getOrganization() {
		return organization;
	}
	public void setOrganization(Organization organization) {
		this.organization = organization;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public List<ProjSciField> getProjSciField() {
		return projSciField;
	}
	public void setProjSciField(List<ProjSciField> projSciField) {
		this.projSciField = projSciField;
	}
	
	
	
}